<template>
	<view class="content">
		<view class="top_box">
			<view class="top_box_img">
				<image src="../../static/index/index_top_pad.png" mode="aspectFill" v-if="isPad==1"></image>
				<image src="../../static/index/index_top.png" mode="aspectFill" v-else></image>
			</view>
		</view>
		<view class="con">
			<view class="con_box">
				<view class="f32 gray3 fb mb10">我的词库</view>
				<view class="mb10">
					<u-line-progress :striped="true" :percent="percent" :striped-active="true" :show-percent="false"
						active-color="#387BEF"></u-line-progress>
				</view>
				<view class="con_box_cur">
					<view class="con_box_cur_img mr30 white">
						<image :src="`${imgUrl}${courseImage}`" mode=""></image>
						<!-- <view class="con_box_cur_name">
							{{ list.name }}
							<view class="cur_box_z">{{ list.grade }}</view>
						</view> -->
					</view>
					<view class="">
						<view class="d-b-c">
							<view class="f32 fb gray3" style="margin: 0 20rpx 10rpx;">{{ courseName }}</view>
							<view class="f24 gray6" style="min-width: 86rpx;" @click="goPage('/pages/indexhome/chapter?current='+courseId)">
								修改 <u-icon name="arrow-right" color="#666666" size="24"></u-icon>
							</view>
						</view>
						<view class="f26 gray6 ml20">{{ studyNum }}/{{ totalNum }}</view>
					</view>
				</view>
			</view>

			<view class="bot_box d-b-c">
				<view class="bot_box_dc" @tap="goPage('/pages/study/study?courseId='+courseId)">
					<view class="">
						<image src="/static/index/word_icn.png" mode=""></image>
					</view>
					<view class="f32 fb mt30">单词识记</view>
				</view>
				<view class="bot_box_dc2">
					<view class="bot_box_fx" @tap="goPage('/pages/indexhome/review')">
						<view class="">
							<image src="/static/index/review_icn.png" mode=""></image>
						</view>
						<view class="f32 fb mt20">趣味复习</view>
					</view>
					<view class="bot_box_fx mt20" @tap="goPage('/pages/study/review21')">
						<view class="">
							<image src="/static/index/forget_icn.png" mode=""></image>
						</view>
						<view class="f32 fb mt20">21天抗遗忘</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isPad: getApp().globalData.isPad,
				imgUrl: getApp().globalData.imgUrl,
				courseId: 0,
				courseName: '',
				courseImage: '',
				totalNum: 0,
				studyNum: 0,
				percent: 0,
			}
		},
		onLoad() {
			if (!this.$store.state.isLogin) {
				uni.$u.toast('登录超时请重新登录')
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/login/login',
					});
				}, 1500)
				return false
			}
		},
		onShow() {
			this.getCurrentCourse()
		},
		methods: {
			reload() {
				this.$nextTick(() => {
					this.getCurrentCourse()
				})
			},
			getCurrentCourse() {
				this.$u.get(this.$u.api.currentCourse, {}).then((res) => {
					console.log(res)
					let course = res.data
					this.courseId = course.course_id
					this.courseName = course.course_name
					this.courseImage = course.image
					this.totalNum = course.num
					this.studyNum = course.study_num
					this.percent = course.study_num * 100 / course.num
				}).catch((err) => {
					console.log(err)
				})
			},
			goPage(page) {
				uni.navigateTo({
					url: page
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	page {
		background: #F6F9FE;
	}
	
	.content {
		// padding-bottom: 60rpx;
	}

	.top_box {
		width: 100%;

		.top_box_img {
			width: 100%;
			height: 35vh;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.con {
		width: 100%;
		padding: 0 4% 40rpx;
		position: absolute;
		top: 28vh;
		left: 0;
	}
	.con_box {
		height: 25vh;
		background: #FFFFFF;
		border-radius: 30rpx;
		padding: 1vh 30rpx;
		box-sizing: border-box;
		position: relative;
	}

	.con_box_cur {
		margin: 0 10rpx;
		height: 13vh;
		background-color: #F6F7F9;
		border-radius: 20rpx;
		display: flex;
		padding: 1vh;
		box-sizing: border-box;
	}

	.con_box_cur_img {
		width: 110rpx;
		height: 10vh;
		position: relative;

		image {
			width: 100%;
			height: 100%;
		}

		.cur_box_z {
			margin-top: 10rpx;
			font-size: 14rpx;
			background-color: #FFFFFF;
			color: #3F7FED;
			text-align: center;
			padding: 0 6rpx;
		}

		.con_box_cur_name {
			position: absolute;
			top: 10rpx;
			left: 20rpx;
		}
	}

	.bot_box {
		margin-top: 28rpx;

		image {
			width: 85rpx;
			height: 85rpx;
		}

		.bot_box_dc {
			width: 46%;
			height: 34vh;
			border-radius: 30rpx;
			// border: 2rpx dashed #666666;
			background-color: #FFFFFF;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
		}
		.bot_box_dc2{
			width: 46%;
		}
		.bot_box_fx {
			width: 100%;
			height: 16vh;
			border-radius: 30rpx;
			// border: 2rpx dashed #666666;
			background-color: #FFFFFF;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
		}
	}
</style>
